﻿using System.Text;
using Reece.Open.Objects;

namespace Reece.Open.Mvc.Common
{
    public class TopMenu : INestedMenu
    {
        private string _id;
        private string _css;

        public bool RenderScript { get; set; }

        public TopMenu(string id, string css)
        {
            _id = id;
            _css = css;
        }

        public string StartMenu()
        {
            StringBuilder output = new StringBuilder(255);
            output.AppendFormat("<div id='{0}'>", _id);
            output.AppendFormat("<ul class='{0}'>", _css);
            return output.ToString();
        }

        public string FinishMenu()
        {
            string result = "</ul></div>";
            if (RenderScript)
            {
                result += string.Format("<script type=\"text/javascript\">InitHomeMenu('{0}','{1}');</script>", _id, _css);
            }
            return result;
        }
    }
}
